exports.CreateCashPad=function(_args)
{
	var pathimage=Ti.App.Properties.getString('pathimage');
	var bt_height=Ti.App.Properties.getInt('Order_buttonnumber_height')
	var view = Ti.UI.createView({
		width:_args.width,
		height:_args.height,
		backgroundColor: _args.backgroundColor,
		top:0,
		right:_args.right,
		
	})
	//////////////////HEADER ///////////
	var height_header=40
	var view_Header = Ti.UI.createView({
		width:_args.width,
		height:2*height_header,
		backgroundColor: 'Transparent',
		top:10,
		left:0,
	})
	view.add(view_Header)
	var view_Tongcong = Ti.UI.createView({
		width:_args.width,
		height:height_header,
		backgroundColor: 'Transparent',
		top:0,
		left:0,
	})
	view_Header.add(view_Tongcong)
	var txt_Tongcong = Titanium.UI.createLabel({
		text:'Tổng cộng:',
		textAlign:'left',
		color:'Black',
		left:10,
	 	font:{
			fontSize:20,
			fontWeight:'bold',
		 },
	}); 
	view_Tongcong.add(txt_Tongcong)
	
	var txt_Tongcong_value = Titanium.UI.createLabel({
		borderColor: Ti.App.Properties.getString('borderColor'),
	    borderRadius: Ti.App.Properties.getInt('borderRadius'),
	    borderWidth:Ti.App.Properties.getInt('borderWidth'),
		color:'Black',
		borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
	    keyboardType: Titanium.UI.KEYBOARD_DEFAULT,
	    returnKeyType: Titanium.UI.RETURNKEY_SEARCH , 
		textAlign:'center',
		right:10,
		backgroundColor:'white',
		height:height_header,
		width:_args.width/2,
	 	font:{
			fontSize:20,
			fontWeight:'bold',
		 },
	}); 
	view_Tongcong.add(txt_Tongcong_value)
	
	
	var view_Tientra = Ti.UI.createView({
		width:_args.width,
		height:height_header,
		backgroundColor: 'Transparent',
		top:view_Tongcong.height,
		left:0,
	})
	view_Header.add(view_Tientra)
	var txt_Tientra = Titanium.UI.createLabel({
		text:'Tiền trả:',
		textAlign:'left',
		color:'Black',
		left:10,
	 	font:{
			fontSize:20,
			fontWeight:'bold',
		 },
	}); 
	view_Tientra.add(txt_Tientra)
	
	var txt_Tientra_value = Titanium.UI.createLabel({
		borderColor: Ti.App.Properties.getString('borderColor'),
	    borderRadius: Ti.App.Properties.getInt('borderRadius'),
	    borderWidth:Ti.App.Properties.getInt('borderWidth'),
		color:'Black',
		borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
	    keyboardType: Titanium.UI.KEYBOARD_DEFAULT,
	    returnKeyType: Titanium.UI.RETURNKEY_SEARCH , 
		textAlign:'center',
		right:10,
		backgroundColor:'white',
		height:height_header,
		width:_args.width/2,
	 	font:{
			fontSize:20,
			fontWeight:'bold',
		 },
	}); 
	view_Tientra.add(txt_Tientra_value)
	//////////////////FOOTER ///////////
	var Leftbt_footer=10;
	var width_bt_footer=(_args.width-20)/3;
	var view_Footer = Ti.UI.createView({
		width:_args.width-10,
		height:bt_height,
		backgroundColor: 'Transparent',
		bottom:0,
		left:0,
	})
	view.add(view_Footer)
	var bts_Footer=[
		{title:'Giảm %',value:1,func:''},
		{title:'Làm tròn',value:2,func:''},
		{title:'In HĐ',value:3,func:''},
	]
	var createButtonFooter = function (bt) {
		var bt_footer = Titanium.UI.createButton({
			 backgroundColor:'#c0c0c0',
		     borderColor: Ti.App.Properties.getString('borderColor'),
		     borderRadius: Ti.App.Properties.getInt('borderRadius'),
		     borderWidth:Ti.App.Properties.getInt('borderWidth'),
			 color:'Black',
			 backgroundImage:pathimage+'tb2.png',
			 backgroundSelectedImage:pathimage+'bt_Nau_press.png',
			 title:bt.title,
			 value:bt.value,
			 width:width_bt_footer,
		 	 height:bt_height,
		   	 left:Leftbt_footer,
		   	 font:{
				fontSize:20,
				fontWeight:'bold',
			 },
		}); 
		bt_footer.addEventListener('click', function (e) {
			
		
        })
		return bt_footer;
	}
	for (i = 0; i < bts_Footer.length; i++){
        var btadd=createButtonFooter(bts_Footer[i])
		view_Footer.add(btadd);
		Leftbt_footer+=btadd.width;
    }
	//////////////////NUMBER PAD///////////
	var view_Pad = Ti.UI.createView({
		width:_args.width-20,
		height:_args.height-view_Footer.height-view_Header.height-10,
		backgroundColor: 'Transparent',
		bottom:view_Footer.height,
	})
	view.add(view_Pad)
	//////////////////NUMBER PAD LEFT///////////
	var width_btpad=view_Pad.width/5
	var height_btpad=view_Pad.height/6
	var view_PadLeft = Ti.UI.createView({
		width:width_btpad,
		height:view_Pad.height,
		backgroundColor: 'Transparent',
		bottom:0,
		left:0
	})
	view_Pad.add(view_PadLeft)
	
	var bts_Left=[
		
		{title:'100',value:100,func:'', bottom:0},
		{title:'50',value:50,func:'',   bottom:height_btpad},
		{title:'20',value:20,func:'',   bottom:2*height_btpad},
		{title:'10',value:10,func:'',   bottom:3*height_btpad},
		{title:'5',value:5,func:'',     bottom:4*height_btpad},
		{title:'1',value:1,func:'',     bottom:5*height_btpad},
	
	]
	var createButtonPadLeft = function (bt) {
		var bt_bbt = Titanium.UI.createButton({
			 backgroundColor:'##c0c0c0',
		     borderColor: Ti.App.Properties.getString('borderColor'),
		     borderRadius: Ti.App.Properties.getInt('borderRadius'),
		     borderWidth:Ti.App.Properties.getInt('borderWidth'),
			 color:'White',
			 backgroundImage:pathimage+'bt_Green.png',
			 backgroundSelectedImage:pathimage+'bt_Nau_press.png',
			 title:bt.title,
			 func:bt.func,
			 value:bt.value,
			 width:width_btpad,
		 	 height:height_btpad,
		   	 bottom:bt.bottom,
		  
		   	 font:{
				fontSize:20,
				fontWeight:'bold',
			 },
		}); 
		bt_bbt.addEventListener('click', function (e) {
			//if(e.source.value==5)
			//{
			//	Ti.App.fireEvent(e.source.func);
			//}
		
        })
		return bt_bbt;
	}
	for (i = 0; i < bts_Left.length; i++){
        var bt_view_PadLeft=createButtonPadLeft(bts_Left[i])
		view_PadLeft.add(bt_view_PadLeft);
    }
	//////////////////NUMBER PAD RIGHT///////////
	var view_PadRight= Ti.UI.createView({
		width:width_btpad,
		height:view_Pad.height,
		backgroundColor: 'Transparent',
		bottom:0,
		right:0
	})
	view_Pad.add(view_PadRight)
	
	var bts_Right=[
		
		{title:'',value:100,func:'', bottom:0,backgroundImage:pathimage+'bg_timnhat.png', backgroundSelectedImage:pathimage+'bt_Nau_press.png'},
		{title:'1/n',value:50,func:'',     bottom:height_btpad,backgroundImage:pathimage+'bg_blue.png', backgroundSelectedImage:pathimage+'bt_Nau_press.png'},
		{title:'1/4',value:20,func:'',     bottom:2*height_btpad,backgroundImage:pathimage+'bg_blue.png', backgroundSelectedImage:pathimage+'bt_Nau_press.png'},
		{title:'1/3',value:10,func:'',     bottom:3*height_btpad,backgroundImage:pathimage+'bg_blue.png', backgroundSelectedImage:pathimage+'bt_Nau_press.png'},
		{title:'1/2',value:5,func:'',      bottom:4*height_btpad,backgroundImage:pathimage+'bg_blue.png', backgroundSelectedImage:pathimage+'bt_Nau_press.png'},
		{title:'Tất cả',value:1,func:'',   bottom:5*height_btpad,backgroundImage:pathimage+'bg_tim.png', backgroundSelectedImage:pathimage+'bt_Nau_press.png'},
	
	]
	var createButtonPadRight = function (bt) {
		var bt_bbt = Titanium.UI.createButton({
			 backgroundColor:'##c0c0c0',
		     borderColor: Ti.App.Properties.getString('borderColor'),
		     borderRadius: Ti.App.Properties.getInt('borderRadius'),
		     borderWidth:Ti.App.Properties.getInt('borderWidth'),
			 color:'White',
			 backgroundImage:bt.backgroundImage,
			 backgroundSelectedImage:bt.backgroundSelectedImage,
			 title:bt.title,
			 func:bt.func,
			 value:bt.value,
			 width:width_btpad,
		 	 height:height_btpad,
		   	 bottom:bt.bottom,
		  
		   	 font:{
				fontSize:20,
				fontWeight:'bold',
				
			 },
		}); 
		bt_bbt.addEventListener('click', function (e) {
			//if(e.source.value==5)
			//{
			//	Ti.App.fireEvent(e.source.func);
			//}
        })
		return bt_bbt;
	}
	for (i = 0; i < bts_Right.length; i++){
        var bt_view_PadRight=createButtonPadRight(bts_Right[i])
		view_PadRight.add(bt_view_PadRight);
    }
	
	//////////////////NUMBER PAD CENTER///////////
	var view_PadCenter= Ti.UI.createView({
		width:view_Pad.width-2*view_PadLeft.width,
		height:view_Pad.height,
		backgroundColor: 'Transparent',
		bottom:0,
		left:view_PadLeft.width
	})
	view_Pad.add(view_PadCenter)
	var width_btcenter=view_PadCenter.width/3;
	var height_btcenter=view_PadCenter.height/4;
	var bottom_row1=0;
	var bottom_row2=view_PadCenter.height/4;
	var bottom_row3=2*(view_PadCenter.height/4);
	var bottom_row4=3*(view_PadCenter.height/4);
	
	var right_col1=0;
	var right_col2=view_PadCenter.width/3;
	var right_col3=2*(view_PadCenter.width/3);
	var bts_Center=[
		
		{title:'C',value:-1,func:'',    bottom:bottom_row1,right:right_col1},
		{title:'0',value:0,func:'',     bottom:bottom_row1,right:right_col2},
		{title:',',value:-2,func:'',    bottom:bottom_row1,right:right_col3},
		{title:'9',value:9,func:'',     bottom:bottom_row2,right:right_col1},
		{title:'8',value:8,func:'',     bottom:bottom_row2,right:right_col2},
		{title:'7',value:7,func:'',     bottom:bottom_row2,right:right_col3},
		{title:'6',value:6,func:'',     bottom:bottom_row3,right:right_col1},
		{title:'5',value:5,func:'',     bottom:bottom_row3,right:right_col2},
		{title:'4',value:4,func:'',     bottom:bottom_row3,right:right_col3},
		{title:'3',value:3,func:'',     bottom:bottom_row4,right:right_col1},
		{title:'2',value:2,func:'',     bottom:bottom_row4,right:right_col2},
		{title:'1',value:1,func:'',     bottom:bottom_row4,right:right_col3},
	
	]
	var createButtonPadCenter = function (bt) {
		var bt_bbt = Titanium.UI.createButton({
			 backgroundColor:'##c0c0c0',
		     borderColor: Ti.App.Properties.getString('borderColor'),
		     borderRadius: Ti.App.Properties.getInt('borderRadius'),
		     borderWidth:Ti.App.Properties.getInt('borderWidth'),
			 color:'Black',
			 backgroundImage:pathimage+'tb2.png',
			 backgroundSelectedImage:pathimage+'bt_Nau_press.png',
			 title:bt.title,
			 func:bt.func,
			 value:bt.value,
			 
			 width:width_btcenter,
			 height:height_btcenter,
		   	 bottom:bt.bottom,
		   	 right:bt.right,
		  
		   	 font:{
				fontSize:50,
				fontWeight:'bold',
			 },
		}); 
		bt_bbt.addEventListener('click', function (e) {
			Ti.API.info(e.source.value)
			if(e.source.value===-1)//C - XOA
			{
				txt_Tientra_value.text='';
			}
			else if(e.source.value===-2)// ,
			{
				txt_Tientra_value.text='';
			}
			else
			{
				//txt_Tientra_value.text=txt_Tientra_value.text+e.source.title
				var a=txt_Tientra_value.text
				if(a==null) a='';
				txt_Tientra_value.text=a+e.source.title
			}
        })
		return bt_bbt;
	}
	for (i = 0; i < bts_Center.length; i++){
        var bt_view_PadCenter=createButtonPadCenter(bts_Center[i])
        if(bt_view_PadCenter.value===-1)//C
        {
        	 bt_view_PadCenter.backgroundImage=pathimage+'bt_Black.png';
			 bt_view_PadCenter.backgroundSelectedImage=pathimage+'bt_Nau_press.png';
        }
		view_PadCenter.add(bt_view_PadCenter);
    }
    
    
    
    
	return view;
}
